package com.example.pm.ending.server.service.impl;

import com.example.pm.ending.server.mapper.*;
import com.example.pm.ending.server.module.owner.AddNewOwnerModuleDTO;
import com.example.pm.ending.server.module.owner.OwnerListModuleVO;
import com.example.pm.ending.server.module.owner.OwnerStandardModuleVO;
import com.example.pm.ending.server.module.owner.OwnerUpdateModuleDTO;
import com.example.pm.ending.server.pojo.dto.OwnerUpdateDTO;
import com.example.pm.ending.server.service.IOwnerModuleService;
import com.example.pm.ending.server.service.ec.ownermodule.DeleteOwnerES;
import com.example.pm.ending.server.service.ec.ownermodule.UpdateOwnerES;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.pm.ending.server.service.ec.ownermodule.AddNewOwnerES;
import java.util.List;


@Service
@Slf4j
public class OwnerModuleServiceImpl implements IOwnerModuleService {

    @Autowired
    private DeleteOwnerES deleteOwnerES;
    @Autowired
    private AddNewOwnerES addNewOwnerES;
    @Autowired
    private UpdateOwnerES updateOwnerES;
    @Autowired
    private OwnerModuleMapper ownerModuleMapper;


    @Override
    public void addNewOwner(AddNewOwnerModuleDTO dto) {
        addNewOwnerES.addNewOwner(dto);
    }


    @Override
    public void deleteOwnerById(Long ownerId) {
        deleteOwnerES.deleteOwner(ownerId);
    }

    @Override
    public void ownerEnable(Long ownerId) {
        updateOwnerES.setOwnerEnableState(ownerId,1);
    }

    @Override
    public void ownerDisEnable(Long ownerId) {
        updateOwnerES.setOwnerEnableState(ownerId,0);
    }

    @Override
    public void updateOwnerInfo(OwnerUpdateModuleDTO ownerUpdateModuleDTO) {
        updateOwnerES.updateOwnerInfo(ownerUpdateModuleDTO);
    }

    @Override
    public List<OwnerListModuleVO> getOwnerModuleList() {
        List<OwnerListModuleVO> ownerModuleList = ownerModuleMapper.getOwnerModuleList();
        return ownerModuleList;
    }

    @Override
    public OwnerStandardModuleVO getOwnerModuleStandardById(Long ownerId,Long houseId,String carPortNumber) {
        OwnerStandardModuleVO ownerModuleStandardVO = ownerModuleMapper.getOwnerModuleStandardById(ownerId, houseId, carPortNumber);
        return ownerModuleStandardVO;
    }
}
